#include <regx52.h>
#include "delay.h"

unsigned int note[7] = {190, 170, 150, 143, 127, 113, 100};//0-6

char music[] = 
{
	0,1,2,0,
	2,3,4,4,
	3,5,4,3,2,0,
	1,-4,0,0,'S'
};

unsigned char idx = 0;
unsigned int count = 0;

void play_music(char* ptr_music) 
{
	unsigned int wait = 0;
	
	if(ptr_music[idx] < 0) 
	{
		wait = note[   -1*ptr_music[idx]  ] + 110;
	} else {
		wait = note[   ptr_music[idx]  ];
	}
	delay(wait);
	P1_5  = !P1_5;
	count++;
	if(count * wait > 15000) 
	{
		count = 0;
		idx++;
		if(ptr_music[idx] == 'S') 
		{
			idx = 0;
		}
	}
}


